package com.zcy.day1.homeWork.poke;

import java.util.*;

/**
 * @author lucker
 * @date 2022/5/23 23:34
 */
public class PokeDemo {
    public static void main(String[] args) {
        //将54张牌随机发个4个人  17  17   17  3
        Map<Integer, String> pokes = new HashMap<>();
        String[] types = {"♣", "♥", "♦", "♠"};
        String[] numbers = {"3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A", "2"};
        List<Integer> pokeNumbers = new ArrayList<>();
        Integer index = 0;
        for (String number : numbers) {
            for (String type : types) {
                pokes.put(index, type + number);
                pokeNumbers.add(index);
                index++;
            }
        }
        pokes.put(52, "小♛");
        pokes.put(53, "大♛");
        pokeNumbers.add(52);
        pokeNumbers.add(53);

        Collections.shuffle(pokeNumbers);
        List<Integer> playerNumber1 = new ArrayList<>();
        List<Integer> playerNumber2 = new ArrayList<>();
        List<Integer> playerNumber3 = new ArrayList<>();
        List<Integer> playerNumber4 = new ArrayList<>();

        for (int i = 0; i < 54; i++) {
            if (i < 17) {
                playerNumber1.add(pokeNumbers.get(i));
            } else if (i < 34) {
                playerNumber2.add(pokeNumbers.get(i));
            }else if (i <51){
                playerNumber3.add(pokeNumbers.get(i));
            }else {
                playerNumber4.add(pokeNumbers.get(i));
            }
        }

        Collections.sort(playerNumber1);
        Collections.sort(playerNumber2);
        Collections.sort(playerNumber3);
        Collections.sort(playerNumber4);

        List<String> player1 = new ArrayList<>();
        List<String> player2 = new ArrayList<>();
        List<String> player3 = new ArrayList<>();
        List<String> player4 = new ArrayList<>();

        for (Integer integer : playerNumber1) {
            player1.add(pokes.get(integer));
        }

        for (Integer integer : playerNumber2) {
            player2.add(pokes.get(integer));
        }

        for (Integer integer : playerNumber3) {
            player3.add(pokes.get(integer));
        }

        for (Integer integer : playerNumber4) {
            player4.add(pokes.get(integer));
        }

        System.out.println(player1);
        System.out.println(player2);
        System.out.println(player3);
        System.out.println(player4);


    }

}
